home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-18 | 3.3 KB | 143 lines | [TEXT/CWIE] |
- {
- ********************************************************
-
- Player PRO 4.5.2 -- Music Driver EXAMPLE
-
- Library Version 4.5
-
- To use with CodeWarrior
-
- Antoine ROSSET
- 16 Tranchees
- 1206 GENEVA
- SWITZERLAND
-
- FAX: (+41 22) 346 11 97
- PHONE: (+41 89) 203 74 62
- Email: rosset@dial.eunet.ch
-
- Ported to Pascal by Federico Filipponi (March 1997)
- e-mail: fedefil@fub.it
- fedefil@kagi.com
-
- ********************************************************
- }
-
- program Example;
-
- uses
- Dialogs, Files, Fonts, GestaltEqu, OSUtils, QuickDraw, Resources, Sound, StandardFile,
- Strings, ToolUtils, Types, Windows,
- MAD, RDriver;
-
- type
- MADDriverRecHdl = ^MADDriverRecPtr;
-
- var
- plugFolderName: Str255;
- fileSpec: FSSPec;
- plugType: MADPlugType;
- where: point;
- reply: SFReply;
- aType: SFTypeList;
- iErr: OSErr;
- done: Boolean;
- init: MADDriverSettings;
- canPlay: Boolean;
-
- begin
- {
- /*************** ****************/
- /****** Toolbox Initialization **********/
- /*************** ****************/
- }
- InitGraf(@qd.thePort);
- InitFonts;
- InitWindows;
- TEInit;
- InitMenus;
- InitCursor;
- MaxApplZone;
- MoreMasters;
-
- FlushEvents(everyEvent, -1);
-
- {
- /*******************************************************************************************/
- /****** MAD Library Initialisation : choose the best driver for the current hardware ******/
- /****** ******/
- /****** Standard initialization with 4 tracks... ******/
- /*******************************************************************************************/
- }
-
- MADGetBestDriver(@init);
-
- plugFolderName := 'Music';
- iErr := MADInitLibrary(P2CStr(@plugFolderName), init.sysMemory);
- if (iErr <> noErr) then
- DebugStr('can''t initialize MADLibrary!');
-
- iErr := MADCreateDriver(@init);
- if (iErr <> noErr) then
- DebugStr('can''t create MAD Driver!');
-
- {
- /*********************************/
- /*********************************/
- /*********************************/
- }
-
- Done := FALSE;
- while not Done do
- begin
- FlushEvents(everyEvent, 0);
- aType[0] := 'MADH';
- aType[1] := 'STrk';
- SetPt(where, -1, -1);
- SFGetFile(where, '', nil, 2, @aType, nil, reply);
-
- if not reply.good then
- Done := true
- else
- begin
- canPlay := true;
-
- iErr := FSMakeFSSpec(reply.vRefNum, 0, reply.fName, fileSpec);
-
- { Convert the OSType to MADPlugType }
- OSType2MADPlugType(reply.fType, plugType);
-
- { Is available a plug to open this file? }
- canPlay := MADPlugAvailable(@plugType);
-
- if canPlay then
- begin
- { Load this music with help of Plugs in application folder, in 'Plugs' folder
- or internal resources }
- iErr := MADLoadMusicFSpFile(@plugType, @fileSpec);
- canPlay := (iErr = noErr);
- end;
-
- if canPlay then
- begin
- iErr := MADStartDriver; { Turn interrupt driver function ON }
- iErr := MADPlayMusic; { Read the current partition in memory }
-
- while not Button do
- ;
-
- iErr := MADStopMusic; { Stop reading current partition }
- iErr := MADStopDriver; { Stop driver interrupt function }
-
- iErr := MADDisposeMusic; { Dispose the current music }
- end;
- end;
- end;
-
- iErr := MADDisposeDriver; { Dispose music driver }
- iErr := MADDisposeLibrary; { Close music library }
-
- FlushEvents(everyEvent, 0);
- end.
-
-